import request from '@/utils/request'

//获取spu列表
export function getSpuList(page, limit, category3Id) {
    return request({ url: `/product/${page}/${limit}`, method: 'get', params: { category3Id } })
}

//获取对应的spu
export function getSpuById(spuId) {
    return request({ url: `/product/getSpuById/${spuId}`, method: 'get' })
}

//获取品牌列表
export const getTrademarkList = () => request({ url: `/product/baseTrademark/getTrademarkList`, method: 'get' })

//获取某spu的图标
export const getSpuImgListById = (spuId) => request({ url: `/product/spuImageList/${spuId}`, method: 'get' })

//获取销售属性
export const getSaleAttr = () => request({ url: `/product/baseSaleAttrList`, method: 'get' })

//添加spu||更新spu
export function addOrUpdateSpu(spuInfo) {
    console.log(spuInfo)
    if (spuInfo.id) {
        return request({ url: `/product/updateSpuInfo`, method: 'post', data: spuInfo })
    } else {
        return request({ url: `/product/saveSpuInfo`, method: 'post', data: spuInfo })
    }
}

//通过id删除spu
export function delSpuById(spuId) {
    return request({ url: `/product/deleteSpu/${spuId}`, method: 'delete' })
}